﻿using System;
using System.Linq;
using System.Text;
using System.Data;
using System.Collections.Generic;

namespace ElingOA6_Admin_DSJCJ.BLL
{
    /// <summary>
    /// LinkTypeEntry的业务逻辑简要说明。
    /// </summary>
	public class LinkTypeEntry
	{
        /// <summary>
        /// 组织机构DAL
        /// </summary>
        private readonly DAL.LinkTypeEntry dal = new DAL.LinkTypeEntry();
        /// <summary>
        /// 构造函数
        /// </summary>
        public LinkTypeEntry()
        { }


        /// <summary>
        ///  获得数据列表
        /// <creator>chenly</creator>
        /// <date>2013-7-16</date>
        /// </summary>
        /// <param name="strWhere">查询条件</param>
        /// <returns>DataTableToListLinkTypeEntry</returns>

        public List<ElingOA6_Admin_DSJCJ.Model.LinkTypeEntry> GetModelLinkTypeEntryList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToListLinkTypeEntry(ds.Tables[0]);

        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        /// <creator>chenly</creator>
        /// <date>2013-7-16</date>
        /// <param name="fLinkTypeEntryID">编号</param>
        /// <returns>GetModel列表</returns>
        public Model.LinkTypeEntry GetModel(int fLinkTypeEntryID)
        {

            return dal.GetModel(fLinkTypeEntryID);
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <creator>chenly</creator>
        /// <date>2013-7-16</date>
        /// <param name="model">model对象</param>
        public void Add(Model.LinkTypeEntry model)
        {
            dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <creator>chenly</creator>
        /// <date>2013-7-16</date>
        /// <param name="model">model对象</param>
        public void Update(Model.LinkTypeEntry model)
        {
            dal.Update(model);
        }
        /// <summary>
        /// 批量删除
        /// <creator>chenly</creator>
        /// <date>2013-7-16</date>
        /// </summary>
        /// <param name="linkTypeArray">人员列表</param>
        /// <param name="entityNo">组织机构编号</param>
        public void DelMany(string[] linkTypeArray, string entityNo)
        {
            dal.DelMany(linkTypeArray, entityNo);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        ///  <creator>chenly</creator>
        /// <date>2013-7-16</date>
        /// <param name="fLinkTypeEntryID">编号</param>
        public void DelLinkType(int fLinkTypeEntryID)
        {

            dal.DelLinkType(fLinkTypeEntryID);
        }

        /// <summary>
        ///  获得数据列表
        /// <creator>chenly</creator>
        /// <date>2013-7-16</date>
        /// </summary>       
        /// <param name="dt">DataTable表</param>
        /// <returns>DataTableToListLinkTypeEntry列表</returns>
        public List<Model.LinkTypeEntry> DataTableToListLinkTypeEntry(DataTable dt)
        {
            List<Model.LinkTypeEntry> modelList = new List<Model.LinkTypeEntry>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.LinkTypeEntry model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.LinkTypeEntry();

                    if (dt.Rows[n]["FLinkTypeEntryID"] != null && dt.Rows[n]["FLinkTypeEntryID"].ToString() != "")
                    {
                        model.FLinkTypeEntryID = int.Parse(dt.Rows[n]["FLinkTypeEntryID"].ToString());
                    }
                    if (dt.Rows[n]["FLinkText"] != null && dt.Rows[n]["FLinkText"].ToString() != "")
                    {
                        model.FLinkText = dt.Rows[n]["FLinkText"].ToString();
                    }
                    if (dt.Rows[n]["FDispSeq"] != null && dt.Rows[n]["FDispSeq"].ToString() != "")
                    {
                        model.FDispSeq = int.Parse(dt.Rows[n]["FDispSeq"].ToString());
                    }
                    if (dt.Rows[n]["FLinkURL"] != null && dt.Rows[n]["FLinkURL"].ToString() != "")
                    {
                        model.FLinkURL = dt.Rows[n]["FLinkURL"].ToString();
                    }
                    if (dt.Rows[n]["FOldFileName"] != null && dt.Rows[n]["FOldFileName"].ToString() != "")
                    {
                        model.FOldFileName = dt.Rows[n]["FOldFileName"].ToString();
                    }
                    if (dt.Rows[n]["FNewFileName"] != null && dt.Rows[n]["FNewFileName"].ToString() != "")
                    {
                        model.FNewFileName = dt.Rows[n]["FNewFileName"].ToString();
                    }
                    if (dt.Rows[n]["FExtName"] != null && dt.Rows[n]["FExtName"].ToString() != "")
                    {
                        model.FExtName = dt.Rows[n]["FExtName"].ToString();
                    }
                    if (dt.Rows[n]["FFileContent"] != null && dt.Rows[n]["FFileContent"].ToString() != "")
                    {
                        model.FFileContent = (byte[])dt.Rows[n]["FFileContent"];
                    }
                    if (dt.Rows[n]["FLinkTypeCD"] != null && dt.Rows[n]["FLinkTypeCD"].ToString() != "")
                    {
                        model.FLinkTypeCD = dt.Rows[n]["FLinkTypeCD"].ToString();
                    }
                    if (dt.Rows[n]["FEntityNo"] != null && dt.Rows[n]["FEntityNo"].ToString() != "")
                    {
                        model.FEntityNo = dt.Rows[n]["FEntityNo"].ToString();
                    }

                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// <creator>wangl</creator>
        /// <date>2013-09-09</date>
        /// </summary>
        public List<Model.LinkTypeEntry> GetListByLinkType(string entityNo, string linkTypeCD)
        {
            DataSet ds = dal.GetListByLinkType(entityNo, linkTypeCD);
            return DataTableToList(ds.Tables[0]);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        private List<Model.LinkTypeEntry> DataTableToList(DataTable dt)
        {
            List<Model.LinkTypeEntry> modelList = new List<Model.LinkTypeEntry>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.LinkTypeEntry model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

	}
}
